package com.wx.app.ui.activity;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import com.example.administrator.newemptyapplication.R;
import com.wx.app.mylib.app.BaseActivity;
import com.zhy.autolayout.utils.AutoUtils;
import butterknife.BindView;
import butterknife.ButterKnife;

public class Test3 extends BaseActivity {

    @BindView(R.id.lv_test)
    ListView lvTest;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test3);
        ButterKnife.bind(mActivity);
        initView();
    }

    private void initView() {
        MyAdapter myAdapter = new MyAdapter();
        lvTest.setAdapter(myAdapter);
    }

    public class MyAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return 10;
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder holder;
            if (convertView == null) {
                holder = new ViewHolder();
                //要使用LayoutInflater.from(mActivity).inflate(),否则不生效
                convertView = LayoutInflater.from(mActivity).inflate(R.layout.item_test3, parent, false);
                convertView.setTag(holder);
                //对于listview，注意添加这一行，即可在item上使用高度
                AutoUtils.autoSize(convertView);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            return convertView;
        }
    }

    class ViewHolder {

    }
}
